package com.gjzhao.fmmall.exception;

import com.gjzhao.fmmall.vo.IErrorCode;

/**
 * @Description: 自定义一个异常类 ApiException(重写异常信息)
 *   - 当需要使用时抛出该异常
 * @Author: gjzhao
 * @Date Created in 2022-01-24 11:50 上午
 */
public class ApiException extends RuntimeException {

    /** 异常错误对象 */
    private IErrorCode errorCode;

    public ApiException(IErrorCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
    }

    /**
     * 获取异常码值
     * @return
     */
    public IErrorCode getErrorCode() {
        return errorCode;
    }


    /**
     * 自定义错误异常提示
     * @param message
     */
    public ApiException(String message) {
        super(message);
    }

    public ApiException(Throwable cause) {
        super(cause);
    }

    public ApiException(String message, Throwable cause) {
        super(message, cause);
    }

}
